package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.user.dtos.LoginDto;
import com.heima.user.service.ApUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/api/v1/login")
@Slf4j
@Api(value = "app端用户登录-控制器")
public class ApUserController {
    @Autowired
    private ApUserService apUserService;

    /**
     * 用户登录
     * @param loginDto
     * @return
     */
    @PostMapping("/login_auth")
    @ApiOperation("用户登录")
    public ResponseResult login(@RequestBody LoginDto loginDto){
        log.info("{}",apUserService.login(loginDto));
        return apUserService.login(loginDto);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestParam("phone") String phone , HttpSession session){

        return apUserService.registered(phone,session);
    }

}
